package shujujiegou;

import java.util.HashSet;
import java.util.Set;

public class LinkedList {
    private static class Node {
        public long value;
        public Node next;

        public Node(long value) {
            this.value = value;
            this.next = null;
        }
    }
    private Node head;
    public void createLinkedList(long studentId) {
        Set<Long> numbers = new HashSet<>();  
        while (numbers.size() < 11) {
            numbers.add((long)(Math.random() * 1000));
        }
        
        numbers.add(studentId);
        Node tmp = null;
        for (long num : numbers) {
            if (head == null) {
                head = new Node(num);
                tmp = head;
            } else {
                tmp.next = new Node(num);
                tmp = tmp.next;
            }
        }
    }

    public void display() {
        Node tmp = this.head;
        System.out.print("生成的链表：[");
        while (tmp != null) {
            System.out.print(tmp.value);
            if (tmp.next != null) {
                System.out.print(" -> ");
            }
            tmp =tmp.next;
        }
        System.out.println("]");
    }

    public static void main(String[] args) {
        LinkedList list = new LinkedList();
        long studentId = 20240310016L;
        
        System.out.println("正在生成包含11个随机数和学号的链表...");
        list.createLinkedList(studentId);
        list.display();
    }
}